package java_thinking.unit_9._9_9;

/**
 * @Description : 演练接口工厂模式
 *                模拟：银行业务办理窗口
 * @author: cww
 * @DateTime: 2019/3/8 8:57
 */

/**
 * 大厅引导前台，所有银行服务类型继承基础
 */
interface BusiService {
    /**
     * 银行分个人业务、企业业务、VIP
     *
     * @param type 告诉前台要办理什么业务
     * @return
     */
    String PersonalService(String type);

    String CorpService(String type);

    String VIPService(String type);

}

/**
 * 具体不同类型业务实现
 */
class TypeService implements BusiService {

    /**
     * 银行分个人业务、企业业务、VIP
     * 根据不同业务类型返回不同窗口
     * @param type
     * @return
     */
    @Override
    public String PersonalService(String type) {
        switch (type){
            case "1": return "窗口1";
            case "2": return "窗口2";
            default:return "窗口3";
        }
    }

    @Override
    public String CorpService(String type) {
        switch (type){
            case "1": return "窗口4";
            case "2": return "窗口5";
            default:return "窗口6";
        }
    }

    @Override
    public String VIPService(String type) {
        switch (type){
            case "1": return "窗口7";
            case "2": return "窗口8";
            default:return "窗口9";
        }
    }
}

/**
 * 获取接口对象实例
 */
interface ServiceProvide {
    BusiService provideService();
}

class ServiceGet implements ServiceProvide {

    @Override
    public BusiService provideService() {
        return new TypeService();
    }
}

class Customer {
    public static void goingToBank(ServiceProvide service,String type){
        BusiService s = service.provideService();
        System.out.println(s.PersonalService(type));
        System.out.println(s.CorpService(type));
        System.out.println(s.VIPService(type));
    }

    public static void main(String[] args) {
        goingToBank(new ServiceGet(),"2");
    }
}